package march.firstmarch22.march02;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class Partitioner02 extends Partitioner<Text,Text> {

    @Override
    public int getPartition(Text text,Text text2, int numPartitions) {
        int partition;

        String[] split = text2.toString().split(",");
        String course = split[0];

        if("computer".equals(course)){
            partition = 0;
        }else if("math".equals(course)){
            partition = 1;
        }else if("english".equals(course)){
            partition = 2;
        }else {
            partition = 3;
        }

        return partition;
    }
}
